﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OracleClient;

public partial class dangky : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DataConnection.str = @"Data Source=xe;User ID=ODER;Password=12345";
        view.SetActiveView(view1);
    }
    protected void btndangky1_Click(object sender, EventArgs e)
    {
        mahoa mk = new mahoa();

        
        string tenDN = txtTenDN.Text;
        

        OracleParameter[] abc = new OracleParameter[] {
            new OracleParameter("p_tendn",tenDN),
        };

        DataTable dt = DataConnection.GetDatatableByStoreProcedureNameCursor("NGOCTRAN.sp_getUserByTenDN", abc);
        
        if (dt.Rows.Count > 0)
        {
            lblcheckusername.Text = " Username đã tồn tại. Yều cầu bạn tạo Username khác!";
        }
        else
        {

            //ma hoa mat khau truoc khi luu xuong csdl
            String pass = mk.mahoamk(txtMatkhau.Text, true);
            
            OracleParameter[] thamso = new OracleParameter[]
            {
                new OracleParameter("P_QUYEN","0"),
                new OracleParameter("P_DIACHI",txtDiachi.Text),
                new OracleParameter("P_SDT",txtSDT.Text),
                new OracleParameter("P_EMAIL",txtemail.Text),
                new OracleParameter("P_TENDN",txtTenDN.Text),   
                new OracleParameter("P_MATKHAUDN",pass ),
                new OracleParameter("P_TENUSER", txtTenUsers.Text),           
            };
            
            if (!chbagree.Checked)
            {
                lblagree.Text = " Bạn chưa chắc chắn dữ liệu nói trên là đúng! Mời bạn hãy đảm bảo tính chắc chắn.";
            }
            else
            {

                // insert new user
                DataConnection.GetDatatableByStoreProcedureName("NGOCTRAN.INSERT_USER", thamso);
               

                view.SetActiveView(view2);
            }
        }
    }
    protected void btnhuy_Click(object sender, EventArgs e)
    {
       txtNhaplaipass.Text = txtemail.Text = txtTenUsers.Text = txtMatkhau.Text = txtSDT.Text = txtTenDN.Text = "";
    }
}